'use strict';

//云函数：删除日常账单记录
const db = uniCloud.database(); //打开链接
const collection = db.collection('money'); //指定表

exports.main = async (event, context) => {

	//event为客户端上传的参数
	if (!event._id) {
		return {
			code: 0,
			msg: '请检查传参！'
		};
	}

	let res = await collection.doc(event._id).remove();
	
	//返回数据给客户端
	if (res.deleted) {
		return {
			code: 1,
			msg: '删除成功'
		};
	} else {
		return {
			code: 0,
			msg: '删除失败'
		};
	}
};
